﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace FourKill.Engine
{
    public class Panels : IPaintable
    {
        public static readonly Random _rand = new Random();
        public Panels() { }

        private Brush _brush = new SolidBrush(Color.FromArgb(128, Color.Gray));
        public void Paint(IPaintableContext context)
        {
            try
            {
                int w = context.ViewPort.PixelSize.Width, 
                    h = context.ViewPort.PixelSize.Height;

                var g = context.FrontLayer;
                var x = (h / 6);
                g.FillEllipse(_brush, new Rectangle(8, 8, x + 4, x + 4));
                g.DrawEllipse(Pens.Aquamarine, new Rectangle(10, 10, x, x));



                g.FillRectangle(_brush, new Rectangle(10, h - x - 10, w - 20, x));
                g.DrawRectangle(Pens.Aquamarine, new Rectangle(12, h - x - 8, w - 24, x - 4));
                if (h / 30 > 1)
                {
                    using (Font _font = new Font("Consolas", x / 5, FontStyle.Bold, GraphicsUnit.Pixel))
                    {
                        g.DrawString(
                            "Location: (" + Math.Round(context.Camera.X, 2) + ", " + Math.Round(context.Camera.Y, 2) + ", " + Math.Round(context.Camera.Z, 2) + ")",
                            _font, Brushes.Aquamarine, new Point(16, h - x));
                        g.DrawString(
                            "Bearing: " + Math.Round(context.Camera.BearingDegrees, 2) + "°",
                            _font, Brushes.Aquamarine, new Point(16, h - x + Convert.ToInt32(x / 3)));
                    }
                }

            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("***********************************");
                System.Diagnostics.Debug.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
                System.Diagnostics.Debugger.Break();
            }
        }
    }
}
